package com.itheima.day09;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapBianli {
    public static void main(String[] args) {
        Map<String, Integer> map = new HashMap<>();
        //1.添加数据为map.put,当数据中的key重复时，会覆盖，即为修改数据
        map.put("张三", 99);
        map.put("李四", 98);
        map.put("王五", 97);
        map.put("赵六", 96);
        map.put("赵六",88);
        //键找值遍历
        Set<String> strings = map.keySet();
        for (String key : strings) {
            Integer value = map.get(key);
            System.out.println(key+"---"+value);
        }
        //键值对遍历
        Set<Map.Entry<String, Integer>> entries = map.entrySet();
        for (Map.Entry<String, Integer> entry : entries) {
            String key = entry.getKey();
            Integer value = entry.getValue();
            value+=10;
            System.out.println(key+"---"+value);
        }
        //lambda遍历
        map.forEach((key,value)->{
            value+=20;
            System.out.println(key+"---"+value);
        });
    }
    }
